{extend name="../../admin/view/main"}

{block name='content'}
<form action="{:sysuri()}" class="layui-card layui-form" data-auto="true" method="post">
    <div class="layui-card-body">

        <label class="layui-form-item relative block">
            <span class="help-label"><b>企业名称</b></span>
            <input class="layui-input" name="qymc" placeholder="请输入企业名称" required value='{$vo.qymc|default=""}'>
        </label>

        <label class="layui-form-item relative block">
            <span class="help-label"><b>统一信用代码</b></span>
            <input class="layui-input" name="tyxydm" placeholder="请输入统一信用代码" required value='{$vo.tyxydm|default=""}'>
        </label>

        <div class="layui-form-item label-required-prev">
            <span class="help-label"><b>营业执照</b></span>
            <div class="relative block label-required-null">
                <input class="layui-input think-bg-gray" name="yyzz" placeholder="请上传营业执照" readonly value='{$vo.yyzz|default=""}'>
                <a class="layui-icon layui-icon-upload input-right-icon" data-file data-field="yyzz" data-type="gif,png,jpg,jpeg"></a>
            </div>
        </div>

        <div class="layui-form-item layui-col-xs12">
            <span class="help-label"><b>企业标签</b></span>
            <span class="color-desc margin-left-5"></span>
            <div id="peipeiList" class="xm-select-demo" ></div>
            <input type="hidden" name="qybq" id="qybq" value="{$vo.qybq|default=''}">
        </div>


        <label class="layui-form-item relative block">
            <span class="help-label"><b>企业地址</b></span>
            <input class="layui-input" name="qydz" placeholder="请输入企业地址" required value='{$vo.qydz|default=""}'>
        </label>



        <div class="hr-line-dashed"></div>
        {notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}

        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存数据</button>
            <button class="layui-btn layui-btn-danger" data-history-back data-confirm="确定要取消编辑吗？" type='button'>取消编辑</button>
        </div>
    </div>

</form>

<script>
    $('input[name="cover"]').uploadOneImage();

    $(function () {
        getUserList();
    });
    function getUserList() {
        layui.use('xmSelect', function () {
            $.ajax({
                type: 'get',
                url: "{:url('getQybqList')}",
                data: "",
                dataType: "json",
                success: function (res) {
                    if (res.code) {
                        console.log(res);
                        var datas = [];
                        res.data.forEach(function (item) {
                            var uuid = "{$vo.qybq|default=''}".split(',');
                            if (uuid.length && uuid.findIndex(it => it == item.id) != -1) {
                                datas.push({name: item.name, value: item.id, selected: true});

                            } else {
                                datas.push({name: item.name, value: item.id});
                            }
                        });
                        xmSelect.render({
                            el: '#peipeiList',
                            tips: '请选择企业标签',//选项提示文字
                            filterable: true,//搜索模式
                            data: datas,
                            on: function (data) {
                                var selectArr = data.arr;
                                var seachArr = [];
                                for (var j = 0; j < selectArr.length; j++) {
                                    seachArr.push(selectArr[j].value)
                                }
                                $("#qybq").val(seachArr.toString());
                            }
                        })
                    } else {
                        console.log(res.info);
                    }
                },
                error: function (err) {
                    console.log(err)
                }
            });
        });
    }
</script>
{/block}
